//
//  ldxViewController.m
//  青春音乐OFJH
//
//  Created by mac on 16-11-16.
//  Copyright (c) 2016年 jh.chen. All rights reserved.
//

#import "ldxViewController.h"
#import "ldxmusic.h"
@interface ldxViewController ()<UITableViewDataSource,UITableViewDelegate>
{
    
    UITableView *myTableView;
    
    
    
    NSMutableArray *peopleArr;
}


@end

@implementation ldxViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
       //self.view.backgroundColor = [UIColor orangeColor];
    //1.1 读取plist文件===获取文件的路径
    NSString *filePath = [[NSBundle mainBundle]pathForResource:@"singer .plist" ofType:nil];
    
    //1.2 读取文件，将读取的内容放到数组中
    peopleArr = [NSMutableArray arrayWithContentsOfFile:filePath];
    
    //把3个人物的信息添加到数组中
    //peopleArr = [NSMutableArray arrayWithObjects:liuDic, guanDic, zhangDic, nil];
    
    NSLog(@"peopleArr == %@", peopleArr);
    
    
    //[[peopleArr objectAtIndex:0]objectForKey:@"name"]
    
    //1.初始化
    myTableView = [[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStylePlain];
    
    //2.设置大小和位置
    
    //3.设置相关属性
    
    //4.设置代理和协议
    myTableView.dataSource = self;
    myTableView.delegate = self;
    

    //5.添加到主视图
    [self.view addSubview:myTableView];
    
    
}

//必须实现的数据源方法：每块分多少行
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 4;
}

//必须实现的数据源方法：每行显示什么内容
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    //1.初始化
    UITableViewCell * myCell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"LoLCell"];
    
    ldxmusic *oneLoL =[ldxmusic LDXpeopleWith:[peopleArr objectAtIndex:indexPath.row]];
    
    
    myCell.textLabel.text = oneLoL.singer;
    
    myCell.detailTextLabel.text = oneLoL.singName;
    
    return myCell;
}

//代理方法：设置每行的高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 80.0f;
    
    
    
}



- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
